<?php
	include_once("adb.php");
	class users extends adb {
		function users() {
			adb::adb();
		}
		
		function get_all_users(){
			$query=("SELECT * FROM users");
			return $this->query($query);
		}
		
		function add_user($userId,$firstname,$lastname,$username,$usertype,$pword,$dateCreated){
			$query = ("INSERT INTO users(userId,firstname,lastname,username,usertype,pword,datecreated) values(NULL,'$firstname','$lastname','$username','$usertype','$pword','$dateCreated')");
			return $this->query($query);	
		}
		
		function search_user_by_username($username){
			$query = ("SELECT * FROM users WHERE username LIKE '$username%'");
			return $this->query($query);
		}
		
		function edit_user($firstname, $lastname,$username,$usertype,$userId){
			$query = ("UPDATE users SET firstname='$firstname' , lastname='$lastname', username='$username', usertype='$usertype' WHERE userId=$userId");
			return $this->query($query);
		}
		
		function search_byId($userId){
			$query =("SELECT * FROM users WHERE userId=$userId");
            if(!$this->query($query)){
                return false;
            }
            return $this->fetch();
        }

        function get_userby_username_password($username,$password){
            $query = ("SELECT firstname,lastname,username,usertype,pword FROM users WHERE username='$username' and pword='$password'");
            if(!$this->query($query)){
                return false;
            }
            return $this->fetch();
        }

		
		
		
	/*
	 * Delete or deactivate user by status active/ inactive
	 * assume an admin that adds users and gives passwords
	 * password encryption and decryption
	 * login validation
	 * */
	
	}

